#pragma once 

#include "GEnginePCH.h"

class Particle
{
public:
	Particle() { m_fSize = 1.0f; m_fLifetime = 4.0f; m_fAge = 0.0f; }
	virtual ~Particle() { }
	
	D3DXCOLOR m_Color;
	D3DXCOLOR m_ColorStep;

	float m_fSize;
	float m_fLifetime;
	float m_fAge;

	D3DXVECTOR3 m_vPos; // current position of particle
	D3DXVECTOR3 m_vDir;

	// this function is inline not because it's small, but because it's only called
	// in one place (CParticleEmitter.Update()).  This way we can also dodge the
	// performance hit associated with calling a function many times (remember, we're
	// in a for loop in CParticleEmitter.Update()).

	// your needs may vary.  For example, if you can afford the speed hit, it might
	// be cool to make this a virtual function.
	inline bool Update(float fTimeDelta)
	{
		// age the particle
		m_fAge += fTimeDelta;

		// if this particle's age is greater than it's lifetime, it dies.
		if (m_fAge >= m_fLifetime) {
			return(false); // dead!
		}

		// move particle
		m_vPos += m_vDir * fTimeDelta;   
	
		//change color
		m_Color += m_ColorStep * fTimeDelta;

		return(true); // particle stays alive
	}
};

